library(tidyverse)
library(pdftools)
load(here::here('data/data.RData'))


data %>%
  filter(PY < 2022) %>% 
  group_by(PY) %>%
  count() %>%
  filter(!is.na(PY)) %>%
  rename(`#` = n) %>%
  ggplot(aes(x = PY,y = `#`)) +
  geom_line(
    aes(group = 1), size = 1.3, color = '#444444'
  ) +
  scale_x_continuous(breaks = seq(1997,2021,2)) +
  scale_y_continuous(breaks = seq(0,400,50)) +
  theme_minimal() +
  labs(x = "YEAR") +
  theme(
    axis.text = element_text(color = '#444444'),
    plot.margin = margin(10,10,10,10),
    panel.grid.minor = element_blank(),
    panel.grid.major = element_blank(),
    axis.title.x = element_text(
      margin = margin(t = 10)
    ),
    axis.title.y = element_text(
      margin = margin(r = 10)
    ),
    axis.line.x = element_line(color = '#444444', size = 1.2)
  ) -> plot1
plot1

ggsave(
  plot = plot1,
  filename = here::here('outputs/figure-01.pdf'),
  device = cairo_pdf,
  dpi = 400
)

pdf_convert(
  here::here('outputs/figure-01.pdf'),
  'jpeg',filenames = here::here('outputs/figure-01.jpeg')
)

pdf_convert(
  pdf = here::here('outputs/figure-01.pdf'),
  filenames = "outputs/figure-01.jpeg",
            format = "jpeg", dpi = 400
)
